package roborally;

import Exceptions.ElementPlacementError;
import Exceptions.IllegalCoordinateException;
import Exceptions.ShootException;

/**
 * A class representing walls that can be placed on a board.
 * 
 * @author Jef Keijers/Bachelor of Science: Informatics
 * @version 1.0
 */
public class Wall extends Element {
	
	/**
	 * @effect 	|super()
	 */
	public Wall() {
		super();
	}
	
	/**
	 * @param 	board
	 * @param	x
	 * @param 	y
	 * @throws 	ElementPlacementError
	 * @effect 
	 * 			|board.putElementOnPosition(this,position)
	 */
	public void putWall(Board board, long x, long y) throws ElementPlacementError {
		if (this.getBoard()==null) {		
			try {
				Position position=new Position(x,y,board);					
				if (!(board.getPositionMap().containsKey(position))) 
					board.putElementOnPosition(this,position);
	
			} catch (IllegalCoordinateException e) {
				throw new ElementPlacementError();
			}
		} 	
	}

	/**
	 * @throws 	ShootException
	 * 			| new ShootException()
	 */
	@Override
	public void handleShot() throws ShootException {
		throw new ShootException();
	}
	
	

}
